<template>
  <div v-if="visible">
    <a-modal v-model="show"  :title="dialogTitle" @cancel="close" destroyOnClose @ok="handleOk" closable v-bind="$attrs" >
      <slot></slot>
      <template slot="footer">
         <slot name="btn"></slot>
         <a-button key="back" v-if="hasCancelButton" @click="close">
          取消
        </a-button>
        <a-button key="submit" v-if="hasOkButton" type="primary"  @click="handleOk">
          确定
        </a-button>
      </template>
    </a-modal>
  </div>
</template>
<script>
export default {
  props:{
    //控制显示
   visible:{
     type:Boolean,
     default:false
   },
   //弹窗标题
   dialogTitle:{
     type:String,
     default:'新增'
   },
   //取消按钮
   hasCancelButton:{
     type:Boolean,
     default:true
   },
   //确认按钮
    hasOkButton:{
     type:Boolean,
     default:true
   }
  },
  data() {
    return {
     show:true
    };
  },
  methods: {
    close(){
    this.$emit('update:visible',false)
    },
    handleOk() {
     this.close()
    },
  },
};
</script>
